insheet using ../Data/Raw/raw_accuracysurvey_managers.csv, comma names clear

drop if _n<=13



* participant characteristics

gen gender_male = q9=="Male"
gen gender_female = q9=="Female"
gen gender_nonbinary = q9=="Non-binary"

gen race_white = q1=="White"
gen race_black = q1=="Black or African American"
gen race_other = race_white==0 & race_black==0 // can update later

gen educ_unselective = q17=="Unselective"
gen educ_belavgselective = q17=="Below Average Selectivity"
gen educ_aboavgselective = q17=="Above Average Selectivity"
gen educ_elite = q17=="Highly Selective, Elite"

gen firm_small = q18=="Below 1500 employees"
gen firm_medium = q18=="Between 1500 and 2000 employees"
gen firm_large = q18=="More than 2,000 employees"

* responses about managers
* empty
rename q4_1 p_acceptinterview_1
rename q5_1 p_passinterview_1
rename q6_1 p_acceptoffer_1

* elite white woman
rename q10_1 p_acceptinterview_2
rename q11_1 p_passinterview_2
rename q12_1 p_acceptoffer_2

* elite black woman
rename q36_1 p_acceptinterview_3
rename q37_1 p_passinterview_3
rename q38_1 p_acceptoffer_3

* non-elite black woman
rename q46_1 p_acceptinterview_4
rename q47_1 p_passinterview_4
rename q48_1 p_acceptoffer_4

* elite black man
rename q41_1 p_acceptinterview_5
rename q42_1 p_passinterview_5
rename q43_1 p_acceptoffer_5

* nonelite black man
rename q51_1 p_acceptinterview_6
rename q52_1 p_passinterview_6
rename q53_1 p_acceptoffer_6

* non-elite white woman
rename q26_1 p_acceptinterview_7
rename q27_1 p_passinterview_7
rename q28_1 p_acceptoffer_7

* elite white man
rename q21_1 p_acceptinterview_8
rename q22_1 p_passinterview_8
rename q23_1 p_acceptoffer_8

* nonelite white man
rename q31_1 p_acceptinterview_9
rename q32_1 p_passinterview_9
rename q33_1 p_acceptoffer_9


* reshape
keep responseid p_* gender_* race_* educ_* firm_*
reshape long p_acceptinterview p_passinterview p_acceptoffer  , i(responseid) j(type, string)

destring p_*, replace


gen hm_empty = type=="_1"
gen hm_white = inlist(type,"_2","_7","_8","_9")
gen hm_black = inlist(type,"_3","_4","_5","_6")
gen hm_female = inlist(type,"_2","_3","_4","_7")
gen hm_male = inlist(type,"_5","_6","_8","_9")
gen hm_elite = inlist(type,"_2","_3","_5","_8")
gen hm_nonelite = inlist(type,"_4","_6","_7","_9")

drop type

order responseid gender_* race_* educ_* firm_* p_* hm_*

foreach x in p_acceptinterview p_passinterview p_acceptoffer { 
	replace `x' = `x'/100
}

save "../Data/Clean/clean_accuracy_managers.dta", replace
